﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.IO;

namespace Fantacid303.ProcessAffinityControl.Service
{
	public class Logger : ILogger, IDisposable
	{
		private readonly StreamWriter writer = null;

		public Logger()
		{
			var directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			var fileName = Path.Combine(directory, "ProcessControl.log");
			this.writer = File.CreateText(fileName);
        }

		public void Log(string status, string message)
		{
			this.writer.WriteLine("{0}    {1}", status, message);
		}

		#region IDisposable Members

		public void Dispose()
		{
			if (writer != null)
				writer.Dispose();
		}

		public void Flush()
		{
			this.writer.Flush();
		}

		#endregion
	}
}
